<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
</head>

<body>
    <div id="app">
        <div @click="handleDivClick" :style="styleObj">helloworld</div>
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                styleObj: {
                    // 这里注意两边都要加上引号，注意注意注意！！！
                    color: "red",
                }
            },
            methods: {
                handleDivClick: function () {
                    // 实现连点切换
                    this.styleObj.color = this.styleObj.color === "red" ? "black" : "red";
                }
            }
        })
    </script>
</body>

</html>